#coding=utf-8
'''
Created on 2017-04-27

@author: sandy
'''

from twisted.internet import task

class BaseCounterManager(object):
    
    def __init__(self):
        self.__map = {}
        
    def start(self, interval):
        l = task.LoopingCall(self.onTimer)
        l.start(interval, False)        
    
    def addCount(self, counter, count=1):
        if self.__map.has_key(counter):
            self.__map[counter] += count
        else:
            self.__map[counter] = count
        
    def getAllCounter(self):
        return self.__map.keys()
    
    def getCount(self, counter):
        return self.__map.get(counter, 0)
    
    def clear(self):
        self.__map = {}
        
    def getCounterMap(self):
        return self.__map
        
    def onTimer(self):
        pass

if __name__ == '__main__':
    pass